import React, { lazy } from "react";
import { useRoutes } from "react-router-dom";
// 引入登录模块
import LoginReg from "../pages/LoginReg";
import AccPass from "../pages/LoginReg/AccPass";
import ForgetPass from "../pages/LoginReg/ForgetPass";
import PhoneLogin from "../pages/LoginReg/PhoneLogin";
import Register from "../pages/LoginReg/Register";
//引入购物车模块
import Shopping from "../pages/Shopping";
import ShippAdd from "../pages/Shopping/OrderMag/ShippAdd";
import ShippMag from '../pages/Shopping/OrderMag/ShippMag'
// import ShopMan from "../pages/Shopping/ShopCar/ShopMan";
// import OrderMag from "../pages/Shopping/OrderMag";
import PaySuc from "../pages/Shopping/PaySuc";
import PayYes from "../pages/Shopping/PayYes";
import Tocar from "../pages/Particulars"; //商品详情页
import Toclassify from "../pages/Classify"; //商品分类页
import Tosearch from "../pages/Search"; //商品搜索页
import Tosearchempty from "../pages/Searchempty"; //商品搜索为空页
import Fridayparticulars from "../pages/Fridayparticulars"; //商品搜索为空页
import Error from "../pages/Error"; //商品搜索为空页

//首页
import Home from "../pages/Home";
import HomePage from "../pages/Home/HomePage";
import MyCity from "../pages/Home/MyCity";
import Jfstore from "../pages/Home/Jfstore";
import JfShop from '../pages/Home/Jfstore/JfShop'
import JfYes from "../pages/Home/Jfstore/JfYes";
//个人中心
import MyCenter from "../pages/MyCenter";
import MyMes from "../pages/MyCenter/MyMes";
import LookMes from "../pages/MyCenter/MyMes/LookMes";
import Idea from "../pages/MyCenter/Idea";
import Browse from "../pages/MyCenter/Browse";
import Wallet from "../pages/MyCenter/Mywallet"; //我的钱包
import Personal from "../pages/MyCenter/Personaldata"; //个人资料
import Changephone from "../pages/MyCenter/Changephone/Phone1"; //换绑手机1
import Changephone2 from "../pages/MyCenter/Changephone/Phone2"; //换绑手机2
import Changephone3 from "../pages/MyCenter/Changephone/Phone3"; //换绑手机2
import Changepassword from "../pages/MyCenter/Changepassword"; //修改密码
import Orderevaluate from "../pages/MyCenter/Orderevaluate"; //订单评价
import Jfparticulars from "../pages/Home/Jfstore/Jfshopeparticulars"; //积分商品详情
import Merchant from "../pages/Merchant"; //商家详情
import Newuser from "../pages/Newuser"; //新用户注册介绍
import Mycollect from "../pages/MyCenter/Mycollect";
import Mysite from "../pages/MyCenter/Mysite";
import Addsite from "../pages/MyCenter/Mysite/Addsite";
import Myaccount from "../pages/MyCenter/Myaccount";
import Topup from "../pages/MyCenter/Myaccount/Topup";
import Topupbill from "../pages/MyCenter/Myaccount/Topupbill";
import Myjf from "../pages/MyCenter/MyJf";
import Mybill from "../pages/MyCenter/Mybill";
import Jfbill from "../pages/MyCenter/Jfbill";
import Firday from "../pages/Home/Firday";
import OrdDet from '../pages/MyCenter/Mybill/OrdDet';
import JfDet from '../pages/MyCenter/Jfbill/JfDet'
import Youxbz from "../pages/Home/Youxbz";
const ShopMan = lazy(()=> import('../pages/Shopping/ShopCar/ShopMan'))
const OrderMag = lazy(()=> import('../pages/Shopping/OrderMag'))
// import OrderMag from "../pages/Shopping/OrderMag";
// import ShopMan from "../pages/Shopping/ShopCar/ShopMan";
export default function AppRouter() {
  const element = useRoutes([
    {
      path: "/",
      element: <Home />,
      children: [
        { path: "", element: <HomePage /> }, //首页
        { path: "mycity", element: <MyCity /> },
        { path: "jfstore", element: <Jfstore /> },
        { path: "firday", element: <Firday /> },
      ],
    },
    //积分商城
    {
      path: '/jfshop', element: <JfShop />, children: [
        { path: '', element: <ShippAdd /> },
      ],
    },
    // 积分订单支付成功
    {path:"jfyes",element:<JfYes/>},
    { path: "/tocar", element: <Tocar /> },
    { path: "/toclassify", element: <Toclassify /> },

    // 搜索
    { path: "/tosearch", element: <Tosearch /> },
    //搜索页面为空
    { path: "/tosearchempty", element: <Tosearchempty /> },
    //积分商品详情
    { path: "/jfparticulars", element: <Jfparticulars /> },
    //礼拜五详情
    { path: "/fridayparticulars", element: <Fridayparticulars /> },
    //商家详情
    { path: "/merchant", element: <Merchant /> },
    //新用户注册介绍
    { path: "/newuser", element: <Newuser /> },
    { path: '/youxbz', element: <Youxbz /> },
    // 登录页路由
    {
      path: "/login",
      element: <LoginReg />,
      children: [
        { path: "", element: <AccPass /> }, //账号密码登录
        { path: "phonelogin", element: <PhoneLogin /> }, //手机验证登录
        { path: "forgetpass", element: <ForgetPass /> }, //忘记密码
        { path: "register", element: <Register /> }, //注册账号
      ],
    },

    //购物车路由
    {
      path: "/shop",element: <Shopping />,
      children: [
        { path: "", element: <ShopMan /> }, //我的购物车 非空
        { path: "paysuc", element: <PaySuc /> }, //订单提交成功
        { path: "payyes", element: <PayYes /> }, //支付成功
        //确认订单信息
        {
          path: "ordermag", element: <OrderMag />, children: [
            { path: '', element: <ShippAdd /> },//添加地址模块
            { path: 'shippmag', element: <ShippMag /> },//有地址的模块
          ],
        }, //确认订单信息
      ],
    },

    //个人中心
    {
      path: "/mycenter",
      element: <MyCenter />,
      children: [
        //我的账户
        { path: "myaccount", element: <Myaccount /> },
        { path: "myaccount/topup", element: <Topup /> },
        { path: "myaccount/topupbill", element: <Topupbill /> },
        //我的订单
        { path: "mybill", element: <Mybill /> },
        //我的订单 详情
        { path: "orddet", element: <OrdDet /> },
        //我的积分
        { path: "myjf", element: <Myjf /> },
        //积分订单
        { path: "jfbill", element: <Jfbill /> },
        //积分订单 详情
        { path: "jfdet", element: <JfDet /> },
        //地址管理
        { path: "mysite", element: <Mysite /> },
        //添加地址
        { path: "mysite/addsite", element: <Addsite /> },
        //我的收藏
        { path: "mycollect", element: <Mycollect /> },
        //最近浏览
        { path: "browse", element: <Browse /> },
        //我的信息
        { path: "mymes", element: <MyMes /> },
        //查看我的信息
        { path: "mymes/lookMes", element: <LookMes /> },
        //意见反馈
        { path: "idea", element: <Idea /> },
        //查看我的钱包
        { path: "wallet", element: <Wallet /> },
        //查看个人资料
        { path: "personal", element: <Personal /> },
        //修改手机号第一步
        { path: "changephone", element: <Changephone /> },
        //修改手机号第二步
        { path: "changephone2", element: <Changephone2 /> },
       //修改手机号第三步
        { path: "changephone3", element: <Changephone3 /> },
        //修改密码
        { path: "changepassword", element: <Changepassword /> },
          //订单评价
        { path: "orderevaluate", element: <Orderevaluate /> },
      ],
    },
    //页面404
    { path: "/*", element: <Error /> },
  ]);
  return element;
}
